<template>
  <el-skeleton :loading="loading" animated>
    <template #template>
      <div class="layout">
        <!-- 官方榜 -->
        <div class="official">
          <el-skeleton-item class="txt" variant="text" />
          <!-- <span class="txt">官方榜</span> -->

          <div class="list">
            <div class="list-item" v-for="item in officialList" :key="item.id">
              <div class="left">
                <!-- <el-image :src="item.officialImg" fit="cover"></el-image> -->
                <el-skeleton-item class="el-image" variant="image" />

                <div class="box">
                  <!-- <span class="name">{{ item.officialName }}</span> -->
                  <el-skeleton-item class="name" variant="text" />
                  <el-skeleton-item class="time" variant="text" />
                  <!-- <span class="time">{{ item.updateTime }}</span> -->
                </div>
              </div>

              <div class="right">
                <div class="songs" @click="handleLookOfficialSong">
                  <div
                    class="song-item"
                    v-for="play in item.playList"
                    :key="play.id"
                    :data-name="play.name"
                  >
                    <div class="box">
                      <el-skeleton-item class="id" variant="text" />
                      <!-- <el-icon size="20" color="#E00000" style="margin-left: 10px"
                        ><Upload
                      /></el-icon> -->
                      <el-skeleton-item class="el-icon" variant="image" />
                      <el-skeleton-item class="name" variant="text" />
                      <el-skeleton-item class="hotReview" variant="text" />

                      <!-- <span class="name">{{ play.name }}</span>
                      <span class="hotReview">{{ play.hotReview }}</span> -->
                    </div>
                    <!-- <span class="singer">{{ play.singer }}</span> -->
                    <el-skeleton-item class="singer" variant="text" />
                  </div>
                </div>
                <!-- <div class="more">查看全部</div> -->
                <el-skeleton-item class="more" variant="text" />
              </div>
            </div>
          </div>
        </div>

        <!-- 全球榜 -->
        <div class="global">
          <!-- <span class="txt">全球榜</span> -->
          <el-skeleton-item class="txt" variant="text" />

          <div class="list">
            <div class="list-item" v-for="item in rankingList" :key="item.id">
              <div class="box">
                <!-- <el-image :src="item.rankImg" fit="cover"></el-image> -->
                <el-skeleton-item class="el-image" variant="image" />
                <el-skeleton-item class="rankname" variant="text" />
                <el-skeleton-item class="playvolume" variant="text" />
                <!--<span class="rankname">{{ item.rankName }}</span>
                <span class="playvolume">{{ item.playVolume }}</span> -->
              </div>
              <!-- <span class="fullname">{{ item.fullName }}</span> -->
              <el-skeleton-item class="fullname" variant="text" />
            </div>
          </div>
        </div>
      </div>
    </template>
  </el-skeleton>
</template>

<script setup>
import { ref, watch } from 'vue'
import { Upload } from '@element-plus/icons-vue'

const loading = ref('')

const officialList = ref([
  {
    id: 0,
    officialImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/1.png',
    officialName: '黑胶榜',
    updateTime: '12月04日更新  ',
    playList: [
      {
        id: 0,
        name: '像你这样的人',
        singer: 'Eminem / Nate Dogg',
        hotReview: '老板，哪位喝蜜桃汽水的女孩常来吗？'
      },
      {
        id: 99,
        name: 'Coming In Hot',
        singer: '周杰伦',
        hotReview: '明明只是删了你却空了整个列表 丢了你'
      },
      {
        id: 18,
        name: '夜的第七章',
        singer: '孙燕姿',
        hotReview: '东野圭吾的小说中，哪些值得推荐？为什么？'
      },
      {
        id: 100,
        name: 'Fast Lane',
        singer: 'Eminem',
        hotReview: '当国语歌被粤语改编，民谣女声吉他弹唱一人搞定男女对唱情歌'
      },
      {
        id: 105,
        name: 'The Real Slim Shady',
        singer: '陈雪凝',
        hotReview: '美图欣赏！Artstation最受欢迎大佬作品列表！'
      }
    ]
  },
  {
    id: 4,
    officialImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/5.png',
    officialName: '黑胶榜',
    updateTime: '12月07日更新  ',
    playList: [
      {
        id: 0,
        name: '上学威龙',
        singer: 'Eminem / Nate Dogg',
        hotReview: '老板，哪位喝蜜桃汽水的女孩常来吗？'
      },
      {
        id: 99,
        name: '好想爱这个世界啊',
        singer: '周杰伦',
        hotReview: '明明只是删了你却空了整个列表 丢了你'
      },
      {
        id: 18,
        name: '画',
        singer: '孙燕姿',
        hotReview: '东野圭吾的小说中，哪些值得推荐？为什么？'
      },
      {
        id: 100,
        name: '醉赤壁',
        singer: 'Eminem',
        hotReview: '当国语歌被粤语改编，民谣女声吉他弹唱一人搞定男女对唱情歌'
      },
      {
        id: 105,
        name: '我想，我想',
        singer: '陈雪凝',
        hotReview: '美图欣赏！Artstation最受欢迎大佬作品列表！'
      }
    ]
  },
  {
    id: 5,
    officialImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/9.png',
    officialName: '黑胶榜',
    updateTime: '12月06日更新  ',
    playList: [
      {
        id: 0,
        name: '摩天动物园',
        singer: 'Eminem / Nate Dogg',
        hotReview: '老板，哪位喝蜜桃汽水的女孩常来吗？'
      },
      {
        id: 99,
        name: '光年之外',
        singer: '周杰伦',
        hotReview: '明明只是删了你却空了整个列表 丢了你'
      },
      {
        id: 18,
        name: '夜的第七章',
        singer: '孙燕姿',
        hotReview: '东野圭吾的小说中，哪些值得推荐？为什么？'
      },
      {
        id: 100,
        name: 'Fast Lane',
        singer: 'Eminem',
        hotReview: '当国语歌被粤语改编，民谣女声吉他弹唱一人搞定男女对唱情歌'
      },
      {
        id: 105,
        name: 'The Real Slim Shady',
        singer: '陈雪凝',
        hotReview: '美图欣赏！Artstation最受欢迎大佬作品列表！'
      }
    ]
  }
])

const rankingList = ref([
  {
    rankId: 0,
    rankName: '黑胶榜',
    fullName: '黑胶VIP爱听榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/1.png',
    playVolume: '2619万'
  },
  {
    rankId: 1,
    rankName: '说唱榜',
    fullName: '说唱榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/2.png',
    playVolume: '6692万'
  },
  {
    rankId: 2,
    rankName: '古典榜',
    fullName: '古典榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/3.png',
    playVolume: '6692万'
  },
  {
    rankId: 3,
    rankName: '电音榜',
    fullName: '电音榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/4.png',
    playVolume: '6692万'
  },
  {
    rankId: 4,
    rankName: 'ACG榜',
    fullName: 'ACG榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/5.png',
    playVolume: '5189万'
  },
  {
    rankId: 5,
    rankName: '韩语榜',
    fullName: '韩语榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/6.png',
    playVolume: '892万'
  },
  {
    rankId: 6,
    rankName: '果断榜',
    fullName: '果断榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/7.png',
    playVolume: '5812万'
  },
  {
    rankId: 7,
    rankName: '古典榜',
    fullName: '古典榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/8.png',
    playVolume: '4152万'
  },
  {
    rankId: 8,
    rankName: '傻傻的',
    fullName: '傻傻的',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/9.png',
    playVolume: '6692万'
  },
  {
    rankId: 9,
    rankName: 'poor',
    fullName: 'poor',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/10.png',
    playVolume: '7695万'
  },
  {
    rankId: 10,
    rankName: '黑胶榜',
    fullName: '黑胶VIP爱听榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/11.png',
    playVolume: '2619万'
  },
  {
    rankId: 11,
    rankName: '说唱榜',
    fullName: '说唱榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/12.png',
    playVolume: '6692万'
  },
  {
    rankId: 12,
    rankName: '古典榜',
    fullName: '古典榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/13.png',
    playVolume: '6692万'
  },
  {
    rankId: 13,
    rankName: '电音榜',
    fullName: '电音榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/14.png',
    playVolume: '6692万'
  },
  {
    rankId: 14,
    rankName: 'ACG榜',
    fullName: 'ACG榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/15.png',
    playVolume: '5189万'
  },
  {
    rankId: 15,
    rankName: '韩语榜',
    fullName: '韩语榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/16.png',
    playVolume: '892万'
  },
  {
    rankId: 16,
    rankName: '果断榜',
    fullName: '果断榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/17.png',
    playVolume: '5812万'
  },
  {
    rankId: 17,
    rankName: '古典榜',
    fullName: '古典榜',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/18.png',
    playVolume: '4152万'
  },
  {
    rankId: 18,
    rankName: '傻傻的',
    fullName: '傻傻的',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/19.png',
    playVolume: '6692万'
  },
  {
    rankId: 19,
    rankName: 'poor',
    fullName: 'poor',
    rankImg: 'https://web-tilas4854.oss-cn-beijing.aliyuncs.com/ranking/20.png',
    playVolume: '7695万'
  }
])

const props = defineProps({
  isShowSkeleton: {
    type: Boolean,
    default: true
  }
})

watch(
  () => props.isShowSkeleton,
  () => {
    loading.value = props.isShowSkeleton
  }
)

// 查看点击的是哪一首歌曲
const handleLookOfficialSong = (event) => {
  const target = event.target.closest('.song-item')

  if (target) {
    const songName = target.dataset.name
    console.log('点击的歌曲名称：', songName)
    // 处理逻辑...
  }
}
</script>

<style lang="scss" scoped>
.layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 40px;

  .official {
    padding: 40px 40px;
    border-radius: 20px;
    background-color: #fff;
    .txt {
      max-width: 108px;
      font-size: 32px;
      line-height: 55px;
      color: #363d62;
    }

    .list {
      display: flex;
      flex-direction: column;
      justify-content: center;

      .list-item {
        margin-bottom: 20px;
        display: flex;
        min-width: 1072px;
        max-height: 305px;
        cursor: pointer;
        overflow: hidden;

        .left {
          position: relative;
          width: 250px;
          height: 250px;

          .el-image {
            width: 100%;
            height: 100%;
            filter: blur(5px);
          }

          .box {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

            .name {
              white-space: nowrap;
              font-size: 48px;
              line-height: 67px;
              color: #ffffff;
            }

            .time {
              font-size: 16px;
              line-height: 28px;
              text-align: center;
              color: #ffffff;
            }
          }
        }

        .right {
          flex: 1;
          margin-left: 20px;

          .songs {
            display: flex;
            flex-direction: column;

            .song-item {
              padding: 12px 20px;
              display: flex;
              align-items: center;
              justify-content: space-between;

              .box {
                display: flex;
                align-items: center;
                .id {
                  min-width: 12px;
                  font-size: 20px;
                  line-height: 28px;
                  color: #e00000;
                }

                .el-icon {
                  margin-left: 10px;
                  min-width: 20px;
                  height: 20px;
                }
                
                .name {
                  min-width: 80px;
                  margin-left: 9px;
                  font-size: 18px;
                  line-height: 25px;
                  color: #363d62;
                }

                .hotReview {
                  flex: 1;
                  margin-left: 8px;
                  font-size: 18px;
                  line-height: 25px;
                  color: #bababd;
                }
              }

              .singer {
                min-width: 80px;
                font-size: 18px;
                line-height: 25px;
                color: #bababd;
              }
            }
          }

          .more {
            max-width: 105px;
            margin-left: 20px;
            cursor: pointer;
            font-size: 18px;
            line-height: 25px;
            color: #363d62;
          }
        }

        &:last-child {
          margin-bottom: 0;
        }
      }
    }
  }

  .global {
    margin-top: 40px;
    padding: 40px 40px;
    border-radius: 20px;
    background-color: #fff;
    .txt {
      max-width: 105px;
      font-size: 32px;
      line-height: 55px;
      color: #363d62;
    }
    .list {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      grid-gap: 20px;
      // max-width: 1136px;

      .list-item {
        display: flex;
        flex-direction: column;
        cursor: pointer;

        .box {
          position: relative;
          display: flex;
          align-items: center;
          justify-content: center;

          .el-image {
            width: 180px;
            height: 180px;
          }
          
          .rankname {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

            white-space: nowrap;
            font-size: 40px;
            line-height: 56px;
            text-align: center;
            color: #ffffff;
          }

          .playvolume {
            position: absolute;
            top: 10px;
            right: 10px;

            z-index: 999;
            max-width: 105px;
            font-size: 18px;
            line-height: 25px;
            letter-spacing: 0px;
            color: #ffffff;
          }
        }
        .fullname {
          margin-top: 12px;
          font-size: 18px;
          line-height: 25px;
          color: #363d62;
        }
      }

      .list-item:hover {
        animation: moveUp 0.1s linear forwards;
      }

      @keyframes moveUp {
        0% {
          transform: translateY(0);
        }
        50% {
          transform: translateY(-5px);
        }
        100% {
          transform: translateY(-12px);
        }
      }
    }
  }
}
</style>
